
package zeus.erp.sistema.datos;
import zeus.erp.sistema.entidades.*;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Types;


public class dAgente {
    public static int ActualizaAgente(eAgente p) throws Exception{
        Connection cn = Conexion.getConexion();
        try{
            CallableStatement stm = cn.prepareCall("{call spActualizarAgente(?,?)}");
            stm.setInt(1, p.getId());
            stm.setString(2, p.getCodigo());
            int i = stm.executeUpdate();
            return i;
        }catch(Exception e){
            throw e;
        }finally{
            cn.close();
        }            
    } 
    
   
     public static int InsertarAgente(eAgente p) throws Exception{
        Connection cn = Conexion.getConexion();
        try{
           
            CallableStatement stm = cn.prepareCall("{call spInsertarAgente(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
            stm.setString(1, p.getObjPersona().getNombres());
            stm.setString(2,  p.getObjPersona().getApaterno());
            stm.setString(3,  p.getObjPersona().getAmaterno());
            stm.setString(4,  p.getObjPersona().getCorreo());
            stm.setString(5,  p.getObjPersona().getCelular());
            stm.setInt(6, p.getObjPersona().getTelefono());
            stm.setInt(7,  p.getObjPersona().getEdad());
            stm.setDouble(8,  p.getObjPersona().getTalla());
            stm.setDouble(9,  p.getObjPersona().getPeso());
            stm.setInt(10,  p.getObjPersona().getFnacimiento());
            stm.setBoolean(11,  p.getObjPersona().isSexo());
            stm.setString(12,  p.getObjPersona().getGsanguineo());
            stm.setInt(13,  p.getObjPersona().getDni());
            stm.setString(14,  p.getObjPersona().getLmilitar());
            stm.setString(15, p.getCdiscamec());
            stm.setString(16, p.getLarmas());
            stm.setString(17, p.getCodigo());
            stm.setString(18, p.getCodigo());
            stm.setString(19, p.getEspecialidad());
            stm.setString(20, p.getTiempo_Exp());
            stm.setString(21, p.getEmpresas_trab());
            
          
            int i = stm.executeUpdate();
            return i;
        }catch(Exception e){
            throw e;
        }finally{
            cn.close();
        }            
    } 
    
     
}
